package xyz.yuzegod.megawalls.classes.novice.enderman;

import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import xyz.yuzegod.megawalls.MegaWalls;
import xyz.yuzegod.megawalls.classes.Classes;
import xyz.yuzegod.megawalls.classes.Skill;
import xyz.yuzegod.megawalls.game.GamePlayer;
import xyz.yuzegod.megawalls.game.stage.BattleStage;
import xyz.yuzegod.megawalls.stats.KitStatsContainer;

import java.util.ArrayList;
import java.util.List;

public class ThirdSkill extends Skill
{
    public ThirdSkill(final Classes classes) {
        super("灵魂爆发", classes);
    }
    
    @Override
    public int maxedLevel() {
        return 3;
    }
    
    @Override
    public double getAttribute(final int level) {
        switch (level) {
            case 1: {
                return 4.33;
            }
            case 2: {
                return 6.66;
            }
            case 3: {
                return 8.23;
            }
            default: {
                return 4.33;
            }
        }
    }
    
    @Override
    public List<String> getInfo(final int level) {
        final List<String> lore = new ArrayList<String>();
        if (level == 1) {
            lore.add(" §8▪ §7当你能量达到100%时,");
            lore.add("   §7获得§a" + this.getAttribute(level) + "§7秒生命恢复I效果。");
            return lore;
        }
        lore.add(" §8▪ §7当你能量达到100%时,");
        lore.add("   §7获得§8" + this.getAttribute(level - 1) + " ➜");
        lore.add("   §a" + this.getAttribute(level) + "§7秒生命恢复I效果。");
        return lore;
    }
    
    @Override
    public void upgrade(final GamePlayer gamePlayer) {
        final KitStatsContainer kitStats = gamePlayer.getPlayerStats().getKitStats(this.getClasses());
        kitStats.addSkill3Level();
    }
    
    @Override
    public int getPlayerLevel(final GamePlayer gamePlayer) {
        return gamePlayer.getPlayerStats().getKitStats(this.getClasses()).getSkill3Level();
    }
    
    @Override
    public boolean use(final GamePlayer gamePlayer, final KitStatsContainer kitStats) {
        if (MegaWalls.getInstance().getGame().getStageManager().currentStage() instanceof BattleStage) {
            return true;
        }
        final Player player = gamePlayer.getPlayer();
        if (player.hasPotionEffect(PotionEffectType.REGENERATION)) {
            player.removePotionEffect(PotionEffectType.REGENERATION);
        }
        player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, (int)(this.getAttribute(kitStats.getSkill3Level()) * 20.0), 0));
        return true;
    }
    
    @Override
    public String getSkillTip(final GamePlayer gamePlayer) {
        return null;
    }
}
